/**
 * Created by Administrator on 2016/1/25.
 */
$(function(){
    /*
    *解决IOS fixed定位问题
    * */
    var jinzhi= 0;
    var u = navigator. userAgent, app = navigator. appVersion;
    var isAndroid = u.indexOf( 'Android') > - 1 || u. indexOf('Linux') > -1; /*android终端或者uc浏览器*/
    var isiOS = !! u. match( /\(i[^;]+;( U;)? CPU.+Mac OS X/); /*ios终端*/
    if(isiOS ){
        $(".kf_input"). focus( function(){ /*input获取焦点*/
            $(".kf_top" ).css ("position" ,"absolute" );
            jinzhi=0
        }). blur( function(){
            $( ".kf_top"). css( "position", "fixed");
            jinzhi=1
        })
        document.addEventListener("touchstart", function(){
            jinzhi=1;
            $( ".kf_input"). blur();
            $( ".kf_top"). css( "position", "fixed");
        }, false);
        document.addEventListener("touchmove", function(e){
            if(jinzhi==0){
                e. preventDefault();
                e. stopPropagation();
            }
        },false);
    }
    /*
    * 移动端按钮点击交互效果
    * */
    document.body.addEventListener('touchstart', function () {});
   
    bannner_height("login_top",11/18);
    bannner_height("main_visual",19/36);
    auto_height("mask_register");/*注册遮罩层高度*/
    auto_height("mask_login");/*登录遮罩层高度*/
    auto_height("mask_resetpassword");/*重置密码遮罩层高度*/
    $(window).resize(function(){
        bannner_height("login_top",11/18);
        bannner_height("main_visual",19/36);
        auto_height("mask_register");/*注册遮罩层高度*/
        auto_height("mask_login");/*登录遮罩层高度*/
        auto_height("mask_resetpassword");/*重置密码遮罩层高度*/
    })

    /*
    * 登录banner显示/隐藏
    * */
    $(".login_input").focus(function(){
        $(".login").addClass("pt53");
        $(".login_top").hide();
        if($(".kf_top").css("display")=="none"){
            $(".kf_top").css("display","block")
        }
    }).blur(function(){
        $(".login").removeClass("pt53");
        $(".login_top").show();
        if($(".kf_top").css("display")=="block"){
            $(".kf_top").css("display","none")
        }
    })

})

 /*
    * 遮罩层高度居中
    * */
    function auto_height(css_demo){
        if($("."+css_demo+"")){
            var height = $("."+css_demo+"").height();
            var total_height = $(window).height();
            var residual_height = (total_height-height)/2;
            $("."+css_demo+"").css("top",residual_height);
        }
    }

    /*
    * banner图高度
    * */
    function bannner_height(css_demo,proportion){
        var width = $("."+css_demo+"").width();
        var height = width * proportion;
        $("."+css_demo+"").height(height)
    }